import random
from Solution import Solution
from typing import List

def shortSeller(prices:List) -> int:
    maxprice = 0
    maxprofit = 0
    for price in prices:
        maxprofit = max(maxprice - price, maxprofit)
        maxprice = max(price, maxprice)
    return maxprofit

s = Solution()

def generateSpecialArray(start, end):
    return list(range(start, end + 1))

def generateRandomIntegerArray(length, min_value, max_value):
    return [random.randint(min_value, max_value) for _ in range(length)]


specialArray = generateSpecialArray(100, 9999)
specialA = s.answer(specialArray)
specialE = shortSeller(specialArray)
if specialA != specialE:
    print("Test Failed\nInput:", specialArray, "Expected:", specialE, "Got:", specialA)
    exit(1)

for i in range(10):
    length = random.randint(1, 10**5)  # Random length between 1 and 10^5
    min_value = 1
    max_value = 10**4 - i
    inputArray = generateRandomIntegerArray(length, min_value, max_value)
    a = s.answer(inputArray)
    e = shortSeller(inputArray)
    if a != e:
        print("Test Failed\nInput:", inputArray, "Expected:", e, "Got:", a)
        exit(1)
exit(0)
